package com.KKB.web;


import com.KKB.bean.Student;
import com.KKB.service.StudentService;
import com.KKB.service.impl.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/Educational/student/testStuNo")
public class TestStuNoServlet extends HttpServlet {
    StudentService studentService=new StudentServiceImpl();
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String stuNo = req.getParameter("stuNo");
        Student student = studentService.findByStuNo(stuNo);
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter writer = resp.getWriter();
        if(student!=null){
            writer.println("<script>alert('学号不可用');location.href='/Educational/student/getGradeList';</script>");
        }else {
            writer.println("<script>document.getElementById('msg').innerText='学号可用';</script>");

        }
    }
}
